package com.shrct.businessprocess.budget.impl;

import com.shrct.businessprocess.budget.RCDirectCostRequest;
import com.shrct.businessprocess.budget.RCHasCostBudget;
import com.shrct.businessprocess.budget.impl.RCHasCostBudgetCostRequestImpl;
import com.shrct.businessprocess.budget.proxy.RCDirectCostRequestProxy;
import com.shrct.businessprocess.organization.RCEmployee;
import com.shrct.businessprocess.organization.impl.RCEmployeeImpl;
import edu.fudan.mylang.pf.IObjectFactory;
import javax.persistence.CascadeType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;

@Entity
@DiscriminatorValue("RCDIRECTCOSTREQUEST_TYPE")
public class RCDirectCostRequestImpl extends RCHasCostBudgetCostRequestImpl implements RCDirectCostRequest {
  public RCDirectCostRequestImpl() {
    super();
  }
  
  public RCDirectCostRequestImpl(final RCHasCostBudget budget) {
    super( budget);
    
  }
  
  @JoinColumn(name = "requester_id")
  @ManyToOne(targetEntity = RCEmployeeImpl.class, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
  private RCEmployee requester;
  
  public RCEmployee getRequester() {
    return this.requester;
  }
  
  public RCDirectCostRequest setRequester(final RCEmployee requester) {
    this.requester = requester;
    return this;			
    
  }
  
  public String getEntityName() {
    RCHasCostBudget _budget = this.getBudget();
    String _entityName = _budget.getEntityName();
    String _plus = (_entityName + ":\u8D39\u7528\u8C03\u6574");
    return _plus;
  }
  
  public static RCDirectCostRequest create(final RCHasCostBudget budget, final IObjectFactory objectFactory) {
    com.shrct.businessprocess.budget.RCDirectCostRequest rCDirectCostRequest = new com.shrct.businessprocess.budget.impl.RCDirectCostRequestImpl(
    	budget
    );
    objectFactory.create(rCDirectCostRequest);
    return rCDirectCostRequest;			
    
  }
  
  public static RCDirectCostRequest createRCDirectCostRequestImpl(final RCHasCostBudget budget, final IObjectFactory objectFactory, final Procedure1<RCDirectCostRequest> init) {
    com.shrct.businessprocess.budget.RCDirectCostRequest rCDirectCostRequest = new com.shrct.businessprocess.budget.impl.RCDirectCostRequestImpl(
    	budget
    );
    objectFactory.create(rCDirectCostRequest);
    init.apply(rCDirectCostRequest);
    
    return rCDirectCostRequest;			
    
  }
  
  public RCDirectCostRequestProxy toProxy() {
    com.shrct.businessprocess.budget.proxy.RCDirectCostRequestProxy proxy = new com.shrct.businessprocess.budget.proxy.RCDirectCostRequestProxy();
    proxy.setId(this.getId());
    if(this instanceof edu.fudan.mylang.pf.INamedModelObject){
    	proxy.setName(((edu.fudan.mylang.pf.INamedModelObject)this).getEntityName());
    }
    return proxy;
    
  }
}
